{
  "properties" : { },
  "id" : "copy1733194237056d75296",
  "script" : null,
  "groupId" : "a01229049ea4496dab1bf8538af48dca",
  "name" : "生成仲裁文案(复制)",
  "createTime" : 1741019539083,
  "updateTime" : 1741367987173,
  "lock" : null,
  "createBy" : null,
  "updateBy" : null,
  "path" : "/arbitration_copy",
  "method" : "GET",
  "parameters" : [ ],
  "options" : [ {
    "name" : "require_login",
    "value" : "false",
    "description" : "该接口需要登录才允许访问",
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  } ],
  "requestBody" : "",
  "headers" : [ {
    "name" : "token",
    "value" : "aa2bbdb9-012a-43cf-86fb-1f0c0f830cab",
    "description" : null,
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  } ],
  "paths" : [ ],
  "responseBody" : null,
  "description" : null,
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : null
}
================================
import response;
import log
import http
//查找当前的状态
let trade_no = "202412080849301187"
var order_re = db.table("orders").where().eq("order_no", trade_no).selectOne()
if (order_re != null) {
    log.info("order_re-->" + order_re)
    const requestUrl = "https://api.coze.cn/v3/chat"
    let appkey = "pat_xqSq4XAsAA5QzmBl5JL4teiyOVvCipC2HDWyXXkFMKoKmd6CZ3MaTkI1HV0CMSRM"
    let param = {
        "bot_id": "7445192650988781609",
        "user_id": "123123",
        "stream": false,
        "auto_save_history": true,
        "additional_messages": [{
            "role": "user",
            "content": order_re.content,
            "content_type": "text"
        }]
    }

    var result = http.connect(requestUrl).contentType('application/json').header("Authorization", "Bearer " + appkey).body(param).post().getBody()
    log.info("result" + result)
    // 更新记录

    db_res = db.table("orders").primary("id").update({
        id: order_re.id,
        ai_status: result.data.status, //更新状态
        conversation_id: result.data.conversation_id,
        chat_id: result.data.id,
    })



    //需要记录会话的 Conversation ID 和 Chat ID

    //记录返回的数据，然后定时任务去取

    // {data={id=7446775928421777449, conversation_id=7446775928421761065, bot_id=7445192650988781609, created_at=1733837635, last_error={code=0, msg=}, status=in_progress}, code=0, msg=}


}



// https://api.coze.cn/v3/chat/message/list



return response.text('fail');